package com.study;

/**
 * @program: leetcode
 * @author: jzhou
 * @date: 2022-11-14 10:12
 * @version: 1.0
 * @description: 最长连续递增子序列
 *
 * 给定一个未经排序的整数数组，找到最长且连续递增的子序列，并返回改序列的长度
 *
 * 算法：贪心算法
 **/
public class MaxSeq {
    public static void main(String[] args) {
        System.out.println(findLength(new int[]{1,2,3,4,5,6,2,3,4,3,4,5,6,7}));
    }

    private static int findLength(int[] numbers) {
        int start = 0,max = 0;
        for (int i = 1,len = numbers.length; i < len; i++) {
            if (numbers[i] <= numbers[i - 1]){
                start = i;
            }
            max = Math.max(max,i - start + 1);
        }
        return max;
    }
    private static int findLength1(int[] numbers){
        int start = 0,max = 0;
        for (int i = 1; i < numbers.length; i++) {
            if(numbers[i] <= numbers[i-1]){
                start = i;
            }
            max = Math.max(max,i - start + 1);
        }
        return max;
    }
}
